package soundwave.com.demo.adpater;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import soundwave.com.demo.R;
import soundwave.com.demo.test.LoginList_test;

/**
 * Created by xu on 2017/3/20.
 */

public class LoginList_adapert extends BaseAdapter {

    private LayoutInflater inflater;
    private List<LoginList_test> mData;

    public LoginList_adapert(Context context,List<LoginList_test>mData) {
        this.inflater=LayoutInflater.from(context);
        this.mData=mData;

    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }
    static class ViewHolder{
        public ImageView headimg;
        public TextView title,content;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder=null;
        if (view==null){
            viewHolder=new ViewHolder();
            view=inflater.inflate(R.layout.myinterface_list,null);
            viewHolder.headimg= (ImageView) view.findViewById(R.id.headimg);
            viewHolder.title= (TextView) view.findViewById(R.id.titlename);
            viewHolder.content= (TextView) view.findViewById(R.id.content);
            view.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) view.getTag();
        }
        viewHolder.headimg.setImageResource((Integer) mData.get(i).getImg());
        viewHolder.title.setText((String) mData.get(i).getTitle());
        viewHolder.content.setText((String) mData.get(i).getContent());
        return view;
    }
}
